<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('sys_dicts', function (Blueprint $table) {
            $table->id()->comment('主键');
            $table->string('type_code', 64)->nullable()->comment('字典类型编码');
            $table->string('name', 50)->default('')->comment('字典项名称');
            $table->string('value', 50)->default('')->comment('字典项值');
            $table->integer('sort')->default(0)->comment('排序');
            $table->unsignedTinyInteger('status')->default(0)->comment('状态(1:正常;0:禁用)');
            $table->unsignedTinyInteger('is_default')->default(0)->comment('是否默认(1:是;0:否)');
            $table->string('remark', 255)->default('')->comment('备注');
            // $table->dateTime('create_time')->nullable()->comment('创建时间');
            // $table->dateTime('update_time')->nullable()->comment('更新时间');
            // $table->index('type_code');
            $table->index('status');
            $table->index('is_default');
            $table->foreign('type_code')->references('code')->on('sys_dict_types')->onDelete('cascade');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('sys_dicts');
    }
};
